package cn.dyw.cloudmusic.dao;

import cn.dyw.cloudmusic.entity.Music;
import cn.dyw.cloudmusic.music.vo.Songs;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MusicMapper {
    /**
     */
    @Delete({
        "delete from music",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    /**
     */
    @Insert({
        "insert into music (id, name)",
        "values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR})"
    })
    int insert(Music record);

    /**
     */
    @Insert({
            "insert ignore music (id, name)",
            "values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR})"
    })
    int insertVo(Songs record);

    int insertList(List<Songs> songs);

    /**
     */
    int insertSelective(Music record);

    /**
     */
    @Select({
        "select",
        "id, name",
        "from music",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @ResultMap("cn.dyw.cloudmusic.dao.MusicMapper.BaseResultMap")
    Music selectByPrimaryKey(String id);

    /**
     */
    int updateByPrimaryKeySelective(Music record);

    /**
     */
    @Update({
        "update music",
        "set name = #{name,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Music record);
}